﻿using Framework.Models.Entities;
using Framework.Utility.ViewModels;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Framework.EF.ModelConfigurations
{
    internal class Biz_UserConfiguration : IEntityTypeConfiguration<Biz_User>
    {
        public void Configure(EntityTypeBuilder<Biz_User> entity)
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");
            entity.ToTable("Biz_User"); 
            entity.Property(x => x.UserName).HasMaxLength(50);
            entity.Property(x => x.Password).HasMaxLength(20);
            var entityType = typeof(Biz_User);
            if (typeof(IsDeleted).IsAssignableFrom(entityType))
            {
                entity.HasQueryFilter(f => !f.IsDeleted);
            }
        }
    }
}
